[email protected] - Avoid redundant update_list calls during clear all#13704
[email protected] - Avoid redundant update_list calls during clear all#13704jsharpe1 wants to merge 1 commit intolinuxmint:masterfrom
Conversation
|
what computer are you using? I have a 4 core ryzen3 and clearing 50 notifications takes about 150ms. There's a max of 20 notifications per app as well. |
|
@fredcw This is on my laptop - CPU is 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz. Out of curiosity, I ran the same test (generating 50 notifications and clearing all) on my desktop, and did not have the same performance issue. That's running a 13th Gen Intel(R) Core(TM) i5-13600KF. |
|
It might be worth investigating this further. Are there any other performance issues on your laptop? |
|
I was preparing a PR to fix this exact issue, good to know there was already one. I can attest that the way I use Cinnamon, having a lot of apps that triggers notifications (mainly chat programs but also some custom notifications I have to keep track of things to do) I tend to read them but not dismiss them. This make it so I regularly find myself with 100+ notifications and on my hardware (AMD Ryzen 7, 32GB RAM) clearing them takes some seconds (just tested: 5s more or less). Not a big problem per se, but the whole UI freezes and it bothers me a bit, since it's a relatively simple fix (IMHO). My fix would have been just this: But I'm no Cinnamon expert. With this change the clearing is immediate. |
|
@enodari Yes, your method is better as it's not as complicated. @jsharpe1 Do you want to update this PR to @enodari 's method or should I create a new one? I just tested again with 40 notifications and it took about 2 seconds and about 38ms with this speedup. I'm not sure why it takes longer sometimes and not other times but in any case, this is still a 10x - 100x speedup so well worth it I think. |
5ce8dc2 to
f219567
Compare


Problem
When clearing all notifications, each
notification.destroy()triggers the destroy signal handler, which callsupdate_list()individually. With N notifications, this results in N+1 calls toupdate_list(), each recalculating urgency, updating icons/labels, reordering children, and requesting a relayout. When the notification count gets high, there is a noticeable hang when it clears all notifications. 50 notifications took 6.5 seconds to clear (see screenshot below).Fix
Added a
_clearingflag that causes the destroy handler to skipupdate_list()during bulk clear. The singleupdate_list()call at the end of_clear_all()handles final state. Wrapped in try/finally to guarantee the flag resets if a destroy call throws.Testing
Tested on Cinnamon 6.6.7 by triggering 50 notifications and clearing all. Verified via Looking Glass:
** Before: **

** After: **

Also verified: